<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>统计星号</title>
</head>
<body>
  <script>
    function fn(s) {
      let count = 0, is = true
      for (let cur of s) {
        // 判断is为true，并且cur字符串为*，就+1
        if (is && cur == '*') count += 1;
        // 判断cur字符串为|，is取反
        if (cur == '|') is = !is;
      }
      return count
    }
    console.log(fn('l|*e*et|c**o|*de|'))
  </script>
</body>
</html>